-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opaque robj: add get/set methods and remove all robj->ptr refs #1658
base: unstable
Are you sure you want to change the base?
Conversation
…nces Signed-off-by: Rain Valentine <[email protected]>
Signed-off-by: Rain Valentine <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1658 +/- ##
============================================
- Coverage 71.02% 71.01% -0.02%
============================================
Files 121 121
Lines 65176 65218 +42
============================================
+ Hits 46290 46313 +23
- Misses 18886 18905 +19
|
Awesome! Tbh, I'd prefer the complete change in one PR so we can get the benefit in memory usage. A separate commit within the same PR for the assignments and then a final commit to actually save memory in the object struct. Feel free to write down you regexes so we can review those |
…ject.c Signed-off-by: Rain Valentine <[email protected]>
Ok, I added I could post the python scripts I used, but they're pretty bad. I only worked on them to the extent that it'd save me time - They mangle a few instances but did the bulk of the editing for me. Here's the one I used for the last objectSetVal commit. The json I load is derived from VS Code's "find all references" feature. import json
with open('ptrrefs.json') as f:
refs = json.load(f)
for file in list(refs.keys()):
with open(file, 'r') as src:
lines = src.readlines()
print('====', file, '====')
for (lineno, char) in refs[file]:
lineno -= 1 # line number is 1-based
char -= 1 # char number also 1-based
line = lines[lineno]
count = line.count('->ptr = ')
if count == 0:
continue
assert(count == 1)
(robj, val_ptr) = line.strip()[:-1].split('->ptr = ')
whitespace = line[:len(line) - len(line.lstrip())]
print(lineno, line[:-1])
lines[lineno] = f'{whitespace}objectSetVal({robj}, {val_ptr});\n'
with open(file, 'w') as src:
src.writelines(lines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, very nice. Next thing to try:
- Rename the ptr field to something else, update getval and setval, see if it still compiles and works.
- For EMBSTR, ignore the ptr field and just embed data att the offsetof(ptr) and compute the val dynamically. We may need to keep pointer field so we don't affect the sizeof(robj) because we have arrays of robjs in some places. Or we can rewrite those in some way maybe.
I wanted to know if I could do this by quickly writing some scripts. It probably took twice as long as I thought, but only 4-5 hours so not terrible, and now I know. 🤷🏻♀️ All but the necessary references in object.c have been replaced using objectGetVal and objectSetVal.
I know we want to make robj opaque so it's easier to refactor it or change its internal structure. I thought there was an issue for this but I can't find it offhand.